import * as tsVfs from "@typescript/vfs";
import * as ts from "typescript";

const compilerOptions = {} as ts.CompilerOptions;
const fsMap = await tsVfs.createDefaultMapFromCDN(
  compilerOptions,
  ts.version,
  true,
  ts,
);
fsMap.set("index.ts", 'console.log("Hello World")');

const system = tsVfs.createSystem(fsMap);
const host = tsVfs.createVirtualCompilerHost(system, compilerOptions, ts);

const program = ts.createProgram({
  rootNames: [...fsMap.keys()],
  options: compilerOptions,
  host: host.compilerHost,
});

// This will update the fsMap with new files
// for the .d.ts and .js files
program.emit();

// Now I can look at the AST for the .ts file too
const index = program.getSourceFile("index.ts");
